<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  .weui-cells__title {
    text-align: left;
  }
  .oitem {
    padding: 3px;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  .weui-label {
    text-align: left;
  }
</style>
<template>
  <div class="oitem">
    <input type="hidden" :name="'items[' + itemNo + '].linkid'" :value="product.guid" />
    <input type="hidden" :name="'items[' + itemNo + '].itemguid'" :value="product.guid" />
    <input type="hidden" :name="'items[' + itemNo + '].productguid'" :value="product.productid" />
    <input type="hidden" :name="'items[' + itemNo + '].productname'" :value="product.product" />
    <input type="hidden" :name="'items[' + itemNo + '].spguid'" :value="product.speid" />
    <input type="hidden" :name="'items[' + itemNo + '].rawspguid'" :value="product.speid" />
    <input type="hidden" :name="'items[' + itemNo + '].stockunit'" :value="product.stockunit" />
    <input type="hidden" :name="'items[' + itemNo + '].stockunitid'" :value="product.stockunitid" />
    <input type="hidden" :name="'items[' + itemNo + '].cospguid'" :value="product.cospguid" />
    <div class="weui-cells__title">货品明细 {{itemNo + 1}}</div>
    <div class="weui-cell fir">
      <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.product">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">规格</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.spename">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">数量{{product.stockunit ? `(${product.stockunit})` : ''}}</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input weight" type="number" :name="'items[' + itemNo + '].weight'" placeholder="请输入数量">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label for="" class="weui-label">库间</label></div>
      <div class="weui-cell__bd">
        <select class="weui-select houseroom" :name="'items[' + itemNo + '].shrguid'" >
          <option value="0">请选择库间</option>
          <option v-for="(hou, i) in houses" :value="hou.value">{{hou.title}} &nbsp; ({{hou.storeqty}} {{hou.unit}})</option>
        </select>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OutStoreRmItem',
  data () {
    return {
      houses: []
    }
  },
  props: [
    'itemNo',
    'product',
    'orgid',
    'strmid',
  ],
  computed: {
  },
  watch: {
    'product': function (val) {
      this.getHouses();
    },
    'orgid': function (val) {
      this.getHouses();
    },
    'strmid': function (val) {
      this.getHouses();
    }
  },
  mounted() {
    this.getHouses();
  },
  methods: {
    getHouses: function() {
      if (!this.checkNull(this.orgid) || !this.checkNull(this.strmid) || !this.checkNull(this.product.productid)) return;
      this.axios({
        method: 'get',
        url: '/sales/Whoutform!getPLInfo.action',
        params: {orgid: this.orgid, strmid: this.strmid, picktype: this.product.picktype, productid: this.product.productid, spec: this.product.speid}
      }).then(response => {
        if (response.data.houses != undefined) {
          this.houses = response.data.houses.map(this.filterHouse);
        } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
          //不不设置提示
        } else {
          this.toastError('系统错误');
        }
      });
    },
    filterHouse: function(item) {
      return {title: item.storeroomName, value:item.storeroomguid, storeqty:item.storeqty, unit:item.unit, productid:item.productid};
    }
  }
}
</script>
